<template>
	<view class="add page c00" >
		<view class="bgf7 p12">
			<view class="bgff px14 pb10">
				
				<view class="flex flexC  py12" >
					<text class="flex1">分类名</text>
					<input v-model="name" class="aliR py3" placeholder="请输入分类的名字" />
					<text class="arrowR ml3"></text>
				</view>
			
			</view>
			<view class="flex flexC flexJC py20">
				<view class="aliC py12 w-17 bg41 r40" @click="save">保存</view>
			</view>
		</view>
		
	
		
		
		
	</view>
</template>

<script>
	
	export default {
		components: {},
		data() {
			return {
		
				name:'',
				shop_id:'',
				id:'',
				name:''
			
			};
		},
		onLoad(option) {
			this.shop_id = option.shop_id;
			if(option.id){
				this.id = option.id;
				this.name = decodeURIComponent(option.name);
				
			}
		},
		
		onShow() {
		
		},
		methods:{
			
		
			save() {
				
				if(this.name == ''){
					
					uni.showToast({
						title:"请填写分类名",
						icon:'none'
					})
					return;
				}
				
				
				let param = {
					shop_id: this.shop_id,
					name:this.name,
					id:this.id
					
				};
				let that = this;
				this.$api.onlineCateAdd(param).then(res => {
			
					if (res.code == 1) {
						uni.showModal({
							title:"添加提示",
							content:"添加成功",
							showCancel:false,
							complete() {
								uni.navigateBack({
									delta:1
								})
							}
						})
					} else {
						uni.showToast({
							title:res.msg,
							icon:'none'
						})
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
.add {
	.w48 {width: 96rpx;height: 96rpx;}
	.imgbox {
		width: 164rpx;height: 164rpx;background-color: #E8E8E8;
		position: relative;
		image {width: 100%;height: 100%;}
		.del {
			width: 36rpx;height: 36rpx;background:rgba(181, 180, 180,.8);
			position: absolute;top: -12rpx;right: -12rpx;
		}
	}
}

.popup-content2 {
		background: #FFFFFF;

		.popup-btn {
			width: 100%;
			height: 100rpx;
			line-height: 100rpx;
			text-align: center;
			border-bottom: 1px solid #f5f5f5;
			background: #FFFFFF;
		}

		.button {
			width: 100%;
			height: 100rpx;
			line-height: 100rpx;
			text-align: center;
			border-bottom: 1px solid #f5f5f5;
			background: #FFFFFF;
			font-size: 11pt;
		}

		button::after {
			border: none;
		}

		.pt20 {
			border-bottom: 20rpx solid #f5f5f5;
		}
	}
</style>
